import java.util.Arrays;

public class Student {

    String name;
    int age;
    String gender;
    String phone;
    String address;
    String email;
    public Student[] studentList = new Student[6];
    public Student[] tempList = null;

    public Student() {
    }

    public Student(String name, int age, String gender, String phone, String address, String email) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.phone = phone;
        this.address = address;
        this.email = email;
    }
    public Student[] deleteStudent(String keyword) {
        int intdex = -1;
        for (int i = 0; i < studentList.length; i++) {
            if (studentList[i].equals(keyword)) {
                intdex = i;
            }

        }
        if (intdex != -1) {
            for (int i = intdex; i < studentList.length-1; i++) {
                studentList[i] = studentList[i + 1];
            }
            Student[] copyArray = Arrays.copyOf(studentList, studentList.length - 1);
            return copyArray;

        }
        return studentList;
    }

    public Student[] addStudent(Student keyword) {

        //数组复制成新的
        Student[] copyArray = Arrays.copyOf(studentList, studentList.length + 1);
        for (int i = 0; i <copyArray.length ; i++) {
            if(null==copyArray[i]){
                copyArray[i]=keyword;
            }

        }
        return  copyArray;

    }
    public  void show(){
        System.out.println("\t姓名\t\t 年龄 \t 性别 \t 电话 \t 地址 \t 电邮");
        for (Student stu: studentList) {
            System.out.println("\t"+stu.name + "\t\t" + stu.age +"\t" +stu.gender
                    + "\t" + stu.phone + "\t" + stu.address + "\t" + stu.email);
        }

    }
}
